-
Notifications
You must be signed in to change notification settings - Fork 44
chore(sdk): [NET-1462] StreamrClient#searchStreams()
queries using Stream
entity
#3132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
StreamrClient#searchStreams()
queries using Stream
entityStreamrClient#searchStreams()
queries using Stream
entity
Added new field to `Stream` entity: `Stream#idAsString`. It has same value as in the `id` field. The field allows us do to substring queries for the field id (by using `idAsString_contains` where clause). This feature is needed e.g. in streamr-dev/network#3132.
…reamPermission entitity
Added new field to `Stream` entity: `Stream#idAsString`. It has same value as in the `id` field. The field allows us to do substring queries for the field id (by using `idAsString_contains` where clause). This feature is needed e.g. in streamr-dev/network#3132.
StreamrClient#searchStreams()
queries using Stream
entityStreamrClient#searchStreams()
queries using Stream
entity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR optimizes the searchStreams functionality in the SDK by switching the GraphQL queries from using the StreamPermission entity to the Stream entity directly, resulting in simpler queries and significant performance improvements.
- Refactored query building in searchStreams to use inline where clauses.
- Updated the SearchStreamsResultItem interface and related transformations in the StreamRegistry.
- Removed the unused createWhereClause utility in TheGraphClient.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
File | Description |
---|---|
packages/utils/src/TheGraphClient.ts | Removed the obsolete createWhereClause function. |
packages/sdk/src/contracts/searchStreams.ts | Refactored the query to use the Stream entity directly and updated filter logic. |
packages/sdk/src/contracts/StreamRegistry.ts | Adjusted response processing to match the new stream query structure. |
CHANGELOG.md | Updated changelog with a reference to the optimization PR. |
Comments suppressed due to low confidence (1)
packages/sdk/src/contracts/searchStreams.ts:16
- The SearchStreamsResultItem interface still defines a 'permissions' field even though the updated GraphQL query only returns 'id' and 'metadata'. Consider updating or removing the 'permissions' field to reflect the actual response data.
export interface SearchStreamsResultItem {
Changed the
StreamrClient#searchStreams()
to useStream
entity directly. The previous implementation used theStreamPermission
entity, which made the queries more complex and slower. See benchmarks below.This also fixes a potential bug as the previous implementation relied on the contents of
StreamPermission#id
to be prefixed with stream id. Most or all of the IDs in our subgraphs have used that kind of id format, but it is not a documented feature of the subgraphs.Benchmarks
The benchmarks were run in
dev2
environment which had ~10000 streamsRelated changes
Removed obsolete
createWhereClause()
method fromTheGraphClient
.